package com.example.bufferedstream;

import java.io.*;

public class BufferedStreamDemo2 {
    public static void main(String[] args) throws IOException {

        /**
         * 字节缓冲流
         * 多个字节
         */

        //创建缓冲流对象
        //字节缓冲输入流
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("src/com/example/file/a.txt"));
        //字节缓冲输出流
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("src/com/example/file/c.txt"));

        //循环读取并写到目的地
        byte[] buf = new byte[256];
        int read = bis.read(buf);
        while (read != -1) {
            System.out.println(read);
            bos.write(buf, 0, read);
            read = bis.read(buf);
        }

        //关闭资源
        bos.close();
        bis.close();

    }
}
